package com.bdqn.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Author 27435
 * @Date 2025/1/915:49
 * @Version 1.0
 */

@Controller
public class LoginController {

    @RequestMapping(value = {"/login"}, method = {RequestMethod.POST})
    public String login(String username, String password, HttpServletRequest request){
        System.out.println(username);
        System.out.println(password);
        // 获取session对象
        HttpSession session = request.getSession();
        if (username.equals("admin") && password.equals("123456")){
            // 登录成功
            session.setAttribute("isLogin", "yes");
        }else {
            return "redirect:/login.jsp";
        }
        return "success-login";
    }

}
